<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../back-common.jsp"%>

<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
<%@ include file="/WEB-INF/pages/common/dialog.jsp"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%
			String curPageNO =  request.getParameter("curPageNO");
			int curpage = 1;
			if ("".equals(curPageNO) || curPageNO == null)
				curpage = 1;
			else {
				curpage = Integer.parseInt(curPageNO);
			}
			Long offset =(Long)request.getAttribute("offset");
	%>
<form:form  id="form1"  action="${contextPath}/admin/member/role/query" method="post">
        <table class="${tableclass}" style="width: 100%">
	    <thead>
	    	<tr><th><strong class="am-text-primary am-text-lg">权限管理</strong> /  角色管理</th></tr>
	    </thead>
	     <tbody><tr><td>
 <div align="left" style="padding: 3px">
			<input type="hidden"  id="curPageNO" name="curPageNO" value="<%=request.getAttribute("curPageNO")%>">
			&nbsp; 名称 <input class="${inputclass}" type="text" name="name" maxlength="50" value="${bean.name }" />
			&nbsp; 应用
						<select id="appNo" name="appNo" class="${selectclass}">
							<ls:optionGroup type="select" required="false" cache="true" beanName="APP_NO" selectedValue="${bean.appNo}"/>
						</select>
		 	&nbsp; 角色类型 
						<select id="category" name="category" class="${selectclass}">
							<ls:optionGroup type="select" required="false" cache="true" beanName="ROLE_CATEGORY" selectedValue="${bean.category}"/>
						</select>
			&nbsp;状态 
					<select id="enabled" name="enabled" class="${selectclass}">
				  			<ls:optionGroup type="select" required="false" cache="true"  beanName="ENABLED" selectedValue="${bean.enabled}"/>
	            	</select>
			<input class="${btnclass}" type="submit" value="搜索"/>
			<input class="${btnclass}" type="button" value="创建角色" onclick='window.location="${contextPath}/admin/member/role/load"'/>
 </div>
 		</td></tr></tbody>
	    </table>
</form:form>	

	 <div align="center">
        <%@ include file="/WEB-INF/pages/common/messages.jsp"%>
    <display:table name="list" requestURI="${contextPath}/admin/member/role/query" id="item" export="false" class="${tableclass}" style="width:100%">
      <display:column title="顺序"  class="orderwidth"><%=offset++%></display:column>
      <display:column title="名称" ><div title="${item.note}">${item.name}</div></display:column>
      <display:column title="角色名称 " property="roleType"></display:column>
      <display:column title="状态">      
      <ls:optionGroup type="label" required="true" cache="true"
	                beanName="ENABLED" selectedValue="${item.enabled}" defaultDisp=""/>
      </display:column>
       <display:column title="所属应用">      
      <ls:optionGroup type="label" required="true" cache="true"
	                beanName="APP_NO" selectedValue="${item.appNo}" defaultDisp=""/>
      </display:column>
      <display:column title="角色类型">      
      <ls:optionGroup type="label" required="true" cache="true"
	                beanName="ROLE_CATEGORY" selectedValue="${item.category}" defaultDisp=""/>
      </display:column>
      <display:column title="对应用户"  style="width: 90px;text-align:center;">
      	<a href="${contextPath}/admin/member/role/loadUserByRole?roleId=${item.id}">用户</a>
      </display:column>
	      <display:column title="操作" media="html" style="width:235px">
	      	<div class="am-btn-toolbar">
			  <div class="am-btn-group am-btn-group-xs">
					<button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="window.location='${contextPath}/admin/member/role/addFunctions/${item.id}'"><span class="am-icon-plus"></span> 分配权限</button>
					<button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="window.location='${contextPath}/admin/member/role/update/${item.id}'"><span class="am-icon-pencil-square-o"></span> 修改</button>
					<button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="deleteById('${item.id}')" ><span class="am-icon-trash-o"></span> 删除</button>
			  </div>
			</div>
	      </display:column>
    </display:table>
       <ls:page pageSize="${pageSize }"  total="${total}" curPageNO="${curPageNO }"  type="default"/>
    </div>
 <script language="JavaScript" type="text/javascript">
 
 	var contextPath = '${contextPath}';
 	
	function deleteById(id) {
	     art.dialog.confirm("确定删除 ?",function(){
	     	window.location = "<ls:url address='/admin/member/role/delete/" + id + "'/>";
	     });
	}
	highlightTableRows("item");
</script>

